unit Thrad_GetCount;

interface

uses
  Classes,SysUtils,Uni,UniConnct,UniConfig,Class_KzThrad;

type
  TThradGetCount = class(TKzThrad)
  public
    FRealCnfg:TUniConfig; //&
    FGetCount:Integer;
    FListTabl:TStringList;//&
  protected
    procedure Execute; override;
  end;

implementation
uses
  ActiveX;

procedure TThradGetCount.Execute;
var
  I:Integer;
  SQLA:string;
  Tabl:string;
  Numb:Integer;
  UniConnct:TUniConnection;
begin
  CoInitialize(nil);
  
  if FRealCnfg=nil then Exit;
  if (FListTabl=nil) or (FListTabl.Count=0) then Exit;

  try
    UniConnct:=UniConnctEx.GetConnection(FRealCnfg);
    //-<
    GetMaxProgress(FListTabl.Count);
    for I:=0 to FListTabl.Count-1 do
    begin
      Tabl:=Trim(FListTabl.Strings[I]);
      SQLA:=Format('SELECT COUNT(1)  AS GETCOUNT FROM %S',[Tabl]);

      Numb:=UniConnctEx.CheckField(SQLA,'GETCOUNT',UniConnct);

      GetMsgProgress('GETCOUNT',[I,FGetCount,Numb]);
      
      GetOneProgress(I+1);
    end;
    
    GetMsgProgress(Class_KzThrad.CONST_THRAD_STAT_TRUE,[]);
    GetMaxProgress(0);
    GetOneProgress(0);
    
    //->
  finally
    FreeAndNil(UniConnct);
  end;        
  CoUninitialize;
end;

end.
